package metric

import (
	"gddgame.cc/galaxy/binocle"
	"github.com/toolkits/nux"
)

func LoadAvg(agent binocle.Service) error {
	if _, err := nux.LoadAvg(); err != nil {
		return err
	}
	agent.AddMetrics().Collect(func() map[string]float32 {
		load, _ := nux.LoadAvg()

		return map[string]float32{
			"load.1min":  float32(load.Avg1min),
			"load.5min":  float32(load.Avg5min),
			"load.15min": float32(load.Avg15min),
		}
	})
	return nil
}
